package org.opportunity.wishlist.travelwish.pojo.model;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity
@Table(name="wishsteps")
public class WishStep implements Serializable, Comparable<WishStep> {

    private static final long serialVersionUID = -4901301155132201276L;
    
    private long id;
    private String propertyName;
    private String propertyDescription;
    private Facet facet;
    private Integer priority;
    
    public WishStep() {
    }
    @Id
    @GeneratedValue
    @Column(name="id")
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }
    
   
    @OneToOne(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
    public Facet getFacet() {
        return facet;
    }

    public void setFacet(Facet facet) {
        this.facet = facet;
    }
    
    @Column(name="property_name")
    public String getPropertyName() {
        return propertyName;
    }
    public void setPropertyName(String propertyName) {
        this.propertyName = propertyName;
    }
    
    @Column(name="property_description")
    public String getPropertyDescription() {
        return propertyDescription;
    }
    public void setPropertyDescription(String propertyDescription) {
        this.propertyDescription = propertyDescription;
    }
    @Column(name="priority")
    public Integer getPriority() {
        return priority;
    }
    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    @Override
    public int compareTo(WishStep obj) {
	int lastCmp = this.priority.compareTo(obj.priority);
	return (lastCmp != 0 ? lastCmp : this.propertyName
		.compareToIgnoreCase(obj.propertyName));
    }
    
    @Override
    public boolean equals(Object obj) {
	if (!(obj instanceof Focus)) {
	    return false;
	}
	WishStep step = (WishStep) obj;
	return step.propertyName.equals(this.propertyName);
    }
   
}
